package com.zho.common.jms.impl;

import java.io.Serializable;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.ObjectMessage;
import javax.jms.Session;
import javax.jms.Topic;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

public class JmsSenderBase {

    private JmsTemplate jmsTemplate;   
    
    /*
     * Send message
     */
    public void sendMessages(final Serializable message, Destination destination) throws JMSException {
            jmsTemplate.send(destination, new MessageCreator() {
                public Message createMessage(Session session) throws JMSException {
                	ObjectMessage objectMessage = session.createObjectMessage(message);
                    return objectMessage;
                }
            });
    }
    
	public JmsTemplate getJmsTemplate() {
		return jmsTemplate;
	}
	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	}
}
